<?php
class yearwidget extends select {
	public $begin;
	public $end;
	
	public function __construct($year = ''){
		$curryear = date('Y');
		if ( strlen($year)){
			$this->selected = $year;
		}
		$this->begin = $curryear - 10;
		$this->end = $curryear + 10;
	}
	
	public function __toString(){
		for ( $i = $this->begin; $i <= $this->end; $i++ ){
			$this->values[$i] = $i;
		}
		return parent::__toString();
	}
	
	public function setBegin($year){
		$this->begin = $year;
	}
	
	public function setEnd($year){
		$this->end = $year;
	}	
	
	public function setRange($begin, $end){
		if ( $begin > $end ){
			$temp = $begin;
			$begin = $end;
			$end = $temp;
		}
		$this->setBegin($begin);
		$this->setEnd($end);
	}
}
?>